<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="vue.js"></script>
    <title>Document</title>
</head>

<body>
    <main id="app">
        <section
            @mousedown.prevent="mousedown"
            @mousemove="mousemove"
            @mouseup="mouseup"
        >
            <img :src="'image/'+img+'.png'" alt="">
        </section>
    </main>
    <script>
        var pageX = 0;
        var start = false;
        var vue = new Vue({
            el: '#app',
            data: {
                img: 0
            },
            methods: {
                mousedown: function ($event) {
                    pageX = $event.pageX;
                    start = true;
                },
                mousemove: function ($event) {
                    if (!start) {
                        return false
                    }
                    var _pageX = $event.pageX;
                    var x = (pageX-_pageX) / 40
                    x = x < 0 ? Math.floor(x) : Math.ceil(x);
                    pageX = _pageX;
                    var num = this.img + x;
                    // 边界判断赋值
                    this.img = num < 0 ?
                        35 + num :
                        num > 35 ? num - 36 : num;
                },
                mouseup: function () {
                    start = false;
                }
            }
            
        })



    </script>
</body>

</html>